import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:psi/widgets/app_bar.dart';

import '../../../../theme/app_colors.dart';
import '../../../../utils/widget_util.dart';
import '../../../../widgets/text_widget.dart';
import 'change_password_logic.dart';

class ChangePasswordPage extends StatelessWidget {
  final logic = Get.find<ChangePasswordLogic>();
  final state = Get
      .find<ChangePasswordLogic>()
      .state;

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: MyAppBar(
        title: "修改密码",
      ),
      body: Container(
        padding: EdgeInsets.all(16),
        child: Column(
            children: [

            WidgetUtil.inputWidget(obscureText: true, showReal: true, height: 40.sp, placeHolder: "请输入密码", onChanged: (value) {
          state.password.value = value;
        }),
        20.verticalSpace,
        WidgetUtil.inputWidget(obscureText: true,
            showReal: true,
            height: 40.sp,
            placeHolder: "请再次输入密码",
            onChanged: (value) {
              state.repeatPassword.value = value;
            }),
        20.verticalSpace,
        Row(
          children: [
            Expanded(child: WidgetUtil.inputWidget(placeHolder: "请输入验证码", height: 40.sp, onChanged: (value) {
              state.code.value = value;
            }),),
            20.horizontalSpace,
            Expanded(
              child: Obx(() {
                return WidgetUtil.getCardItem(
                    onTap: state.getCode.value ? null : logic.sendCode,
                    padding: EdgeInsets.zero,
                    color: state.getCode.value ? Color(0xFFCCCCCC) : primaryColor.withOpacity(0.8),
                    child: Container(
                        height: 40.w,
                        alignment: Alignment.center,
                        child: TextWidget(state.codeBtnTitle.value, color: Colors.white, fontSize: 14.sp, fontWeight: FontWeight.w500,)));
              }),
            ),
          ],
        ),
        20.verticalSpace,
        WidgetUtil.getCardItem(
          onTap: logic.changePassword,
          color: primaryColor.withOpacity(0.8),
          padding: EdgeInsets.zero,
          child: Container(
            height: 40.w,
              width: double.infinity,
              alignment: Alignment.center,
              child: TextWidget(
                "完成",
                color: Colors.white,
                fontWeight: FontWeight.bold,
                fontSize: 16.sp,
              ),
          ),
        ),
          ],
        ),
      ),
    );
  }
}
